//
//  UIScrollView+velocity.m
//  TravelGuideMdd
//
//  Created by 陈曦 on 13-11-29.
//  Copyright (c) 2013年 mafengwo.com. All rights reserved.
//

#import "UIScrollView+velocity.h"
#import <objc/runtime.h>

@implementation UIScrollView(velocity)

- (CGPoint)velocity
{
    return CGPointMake(self.velocityX, self.velocityY);
}

- (double)velocityX
{
    Ivar horizontalVelocity = class_getInstanceVariable(self.class, "_horizontalVelocity");
    double *h = (double*)((const char*)self + ivar_getOffset(horizontalVelocity));
    return *h;
}

- (double)velocityY
{
    Ivar verticalVelocity = class_getInstanceVariable(self.class, "_verticalVelocity");
    double *v = (double*)((const char*)self + ivar_getOffset(verticalVelocity));
    return *v;
}


@end
